home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_pas / rkey31tp.zip / REGKEYW.PAS < prev    next >
Pascal/Delphi Source File  |  1994-06-05  |  10KB  |  202 lines

  1. {
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                                                     R E G K E Y
  8.  
  9.  ------------------------------------------------------------------------------
  10.  
  11.  
  12.                                                                    Version 3.10
  13.  
  14.  
  15.                                     The Registration Key System For Programmers
  16.  
  17.  
  18.                                                  Turbo Pascal/Windows Interface
  19.  
  20.  
  21.  
  22.  
  23.           (C) Copyright Brian Pirie, 1993 - 1994. All Rights Reserved.
  24.  
  25. }
  26.  
  27. unit RegKeyW;
  28.  
  29. interface
  30.  
  31. type
  32.    RKReturn      = (RKFailure, RKSuccess);           { Function return values }
  33.    RKValid       = (RKUnregistered, RKRegistered);   { Key validation results }
  34.  
  35.  
  36.  
  37. { RegKeyNewCodeSet()                                                          }
  38. {                                                                             }
  39. { Generates a registration key validation code corresponding to a             }
  40. { generation code. This set of generation and validation codes is unique      }
  41. { for each application using RegKey, and determines the unique registration   }
  42. { key that corresponds to a particular user's name. The secret generation     }
  43. { code is used at registration key generation time, and the corresponding     }
  44. { validation code is used within your application when validating a           }
  45. { registration key. The validation and generation codes are each              }
  46. { represented as a ten-digit strings of numbers and upper-case letters.       }
  47. {                                                                             }
  48. { This function is called by KeyGen or your own utility, and is only used     }
  49. { once for each application using RegKey.                                     }
  50. {                                                                             }
  51. { sGenerationCode     INPUT: Ten digit generation code                        }
  52. { sValidationCode     OUTPUT: Ten digit validation code                       }
  53.  
  54. function RegKeyNewCodeSet(
  55.       sGenerationCode : string;
  56.       sValidationCode : string)
  57.    : RKReturn;
  58.  
  59.  
  60.  
  61. { RegKeyGenerate()                                                            }
  62. {                                                                             }
  63. { Generates a registration key for a particular user, using the secret        }
  64. { generation code corresponding to a particular application (as passed to     }
  65. { RegKeyNewCodeSet()). The registration string is usually the name of the     }
  66. { registered user, but may also contain other information, such as the        }
  67. { version registered or date of expiry. The registration key is returned as a }
  68. { string of letters and upper-case numbers. sRegKey must be large enough to   }
  69. { hold 20 digits. sRandomSeed should contain 10 random numbers and upper-case }
  70. { letters, which are required during the registration key generation process. }
  71. {                                                                             }
  72. { This function is called by KeyGen or your own registration key generation   }
  73. { utility, each time a registration key is generated for a new user. This     }
  74. { function is used for user-entered registration keys; compare with           }
  75. { RegKeyFileGenerate().                                                       }
  76. {                                                                             }
  77. { sRegString          INPUT: Registration string                              }
  78. { sGenerationCode     INPUT: App's generation code                            }
  79. { sRandomSeed         INPUT: Random number seed                               }
  80. { sRegKey             OUTPUT: 20-digit registration key                       }
  81.  
  82. function RegKeyGenerate(
  83.       sRegString      : string;
  84.       sGenerationCode : string;
  85.       sRandomSeed     : string;
  86.       sRegKey         : string)
  87.    : RKReturn;
  88.  
  89.  
  90.  
  91. { RegKeyValidate()                                                            }
  92. {                                                                             }
  93. { Checks whether a given registration string and registration key             }
  94. { combination is valid for a particular application, using the application-   }
  95. { specific validation code that was generated by RegKeyNewCodeSet(). The      }
  96. { RKVALID pointed to by peRegistered is set to either RK_REGISTERED or        }
  97. { RK_UNREGISTERED, indicating whether or not the registration key and         }
  98. { registration string are valid. If you have registered RegKey, your own      }
  99. { name and RegKey registration key should be passed to this function to       }
  100. { disable the RegKey "unregistered" message.                                  }
  101. {                                                                             }
  102. { This function is called from within your application each time it           }
  103. { executes, in order to determine whether it should operate in registered     }
  104. { or unregistered mode. This function is used with user-entered               }
  105. { registration keys; compare with RegKeyFileValidate().                       }
  106. {                                                                             }
  107. { sRegString          INPUT: Registration string                              }
  108. { sRegKey             INPUT: 20-digit registration key                        }
  109. { sValidationCode     INPUT: App's validation code                            }
  110. { sYourName           INPUT: Your name (if registered)                        }
  111. { nYourKey            INPUT: Your key (if registered)                         }
  112. { peRegistered        OUTPUT: Is key valid                                    }
  113.  
  114. function RegKeyValidate(
  115.       sRegString      : string;
  116.       sRegKey         : string;
  117.       sValidationCode : string;
  118.       sYourName       : string;
  119.       nYourKey        : longint;
  120.   var peRegistered    : RKValid)
  121.    : RKReturn;
  122.  
  123.  
  124.  
  125. { RegFileKeyGenerate()                                                        }
  126. {                                                                             }
  127. { Generates a file-based registration key for a particular user, using the    }
  128. { secret generation code corresponding to a particular application (as        }
  129. { passeed to RegKeyNewCodeSet()). The registration string is usually the      }
  130. { name of the registered user, but may also contain other information, such   }
  131. { as the version registered or date of expiry. A registration key file is     }
  132. { generated, using the specified filename, containing the registration string }
  133. { and the resulting registration key. If a file with the specified name       }
  134. { already exists, it is overwritten. sRandomSeed should contain 10 random     }
  135. { numbers and upper-case letters, which are required during the registration  }
  136. { key generation process.                                                     }
  137. {                                                                             }
  138. { This function is called by KeyGen or your own registration key generation   }
  139. { utility, each time a registration key is generated for a new user. This     }
  140. { function is used for file-based registration keys; compare with             }
  141. { RegKeyGenerate().                                                           }
  142. {                                                                             }
  143. { sRegString          INPUT: Registration string                              }
  144. { sGenerationCode     INPUT: App's generation code                            }
  145. { sRandomSeed         INPUT: Random number seed                               }
  146. { sFileName           INPUT: Registration key file name                       }
  147.  
  148. function RegKeyFileGenerate(
  149.       sRegString      : string;
  150.       sGenerationCode : string;
  151.       sRandomSeed     : string;
  152.       sFileName       : string)
  153.    : RKReturn;
  154.  
  155.  
  156.  
  157. { RegKeyFileValidate()                                                        }
  158. {                                                                             }
  159. { Checks whether the specified registration key file is valid for a           }
  160. { particular application, using the application-specified validation code     }
  161. { that was generated by RegKeyNewCodeSet(). The RKVALID pointed to by         }
  162. { peRegistered is set to either RK_REGISTERED or RK_UNREGISTERED,             }
  163. { indicating whether or not the registration key and registration string      }
  164. { stored in the registration key file are valid. The sFileName parameter      }
  165. { may include wildcards. If you have registered RegKey, your own name and     }
  166. { RegKey registration key should be passed to this function to diable the     }
  167. { RegKey "unregistered" message.                                              }
  168. {                                                                             }
  169. { This function is called from within your application each time it           }
  170. { executes, in order to determine whether it should operate in registered     }
  171. { or unregistered mode. This function is used with file-based registration    }
  172. { keys; compare with RegKeyValidate().                                        }
  173. {                                                                             }
  174. { sFileName           INPUT: Registration key file name                       }
  175. { sValidationCode     INPUT: App's validation code                            }
  176. { sYourName           INPUT: Your name (if registered)                        }
  177. { nYourKey            INPUT: Your key (if registered)                         }
  178. { cbMaxStringSize     INPUT: Characters in reg. string                        }
  179. { sRegString          OUTPUT: Registration string                             }
  180. { peRegistered        OUTPUT: Is key valid                                    }
  181.  
  182. function RegKeyFileValidate(
  183.       sFileName       : string;
  184.       sValidationCode : string;
  185.       sYourName       : string;
  186.       nYourKey        : longint;
  187.       sRegString      : string;
  188.       cbMaxStringSize : byte;
  189.   var peRegistered    : RKValid)
  190.    : RKReturn;
  191.  
  192.  
  193.  
  194. implementation
  195. function RegKeyNewCodeSet; external 'RK31TP';
  196. function RegKeyGenerate; external 'RK31TP';
  197. function RegKeyValidate; external 'RK31TP';
  198. function RegKeyFileGenerate; external 'RK31TP';
  199. function RegKeyFileValidate; external 'RK31TP';
  200.  
  201. end.
  202.